﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Project.Engine.Control;
using Project.Module.Model;
using Project.Module.Model.CMS;
using Project.Module.DAO.CMSBL;
using Project.Module.DAO.BL;
using Project.Engine.Utilities;

namespace Project.Module.View.CMS
{
    public class CMSEditSanPhamView : DocumentInfo
    {
        public List<CategoryModel> listCate = null;
        public List<SupplierModel> listSupplier = null;
        public ProductModel product = null;

        private SupplierBL supplierBl = new SupplierBL();
        private CategoryBL cateBl = new CategoryBL();
        private ProductBL productBL = new ProductBL();
        private ImageBL imageBL = new ImageBL();

        public CMSEditSanPhamView(int nodeid, string nodealias)
        {
            Init(nodeid);
        }

        private void Init(int nodeid)
        {
            listCate = cateBl.GetAllCate();
            listSupplier = supplierBl.GetAllSupplier();

            product = productBL.GetDetailProduct(nodeid);
            if (product != null)
            {
                product.SupplierName = supplierBl.GetSupplierByID(product.SupplierID);
                product.CateName = ConvertUtil.GetCateNameByCateId(product.CatagoryId);
                product.ImagePath = ConvertUtil.ToString(imageBL.GetImagePathById(product.ImageID));
            }
        }
    }
}
